package com.kevin.swing.impl;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.StyledDocument;

import com.kevin.MainFrame;
import com.kevin.swing.TextPaneKevin;

import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = false)
/**
 * 
 * 关于本软件
 * 
 * @ClassName HelpDialog
 * @author <a href="mailto:donggongai@126.com" target="_blank">kevin</a>
 * @date 2017年8月24日 上午10:45:04
 *
 */
public @Data class AboutDialog extends JDialog {
    private MainFrame owner;

    /**
     * 
     */
    private static final long serialVersionUID = 6792501234970299123L;

    private TextPaneKevin wordSetTA;
    private JScrollPane wordSetJsp;

    private JPanel btnPanel = new JPanel();
    private JButton clbtn;

    public AboutDialog(MainFrame owner) {
        super();
        this.owner = owner;
        StyledDocument styledDoc = new DefaultStyledDocument();
        wordSetTA = new TextPaneKevin(styledDoc);
        wordSetTA.setBorder(BorderFactory.createTitledBorder("说明"));

        wordSetTA.insertDoc("数据库表生成实体类");
        wordSetTA.insertHighLightDoc("V 1.0");
        wordSetTA.insertDoc("\n");
        wordSetTA.insertDoc("本软件用于将数据库中的表自动转换为实体类");
        wordSetTA.insertDoc("，可自定义常用词及分词\n");

        wordSetJsp = new JScrollPane(wordSetTA);
        wordSetJsp.setBorder(null);
        clbtn = new JButton("关闭");

        btnPanel = new JPanel();
        btnPanel.add(clbtn);

        setTitle("关于本软件");
        add(wordSetJsp, BorderLayout.CENTER);
        add(btnPanel, BorderLayout.SOUTH);
        setVisible(false);
        setSize(450, 200);
        setResizable(false);
        init();
    }

    private void init() {
        clbtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                AboutDialog.this.setVisible(false);
            }
        });

    }

}
